define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'borrowerinfo/index',
                    add_url: '',
                    edit_url: '',
                    del_url: '',
                    multi_url: 'borrowerinfo/multi',
                    table: 'borrow',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'borrowId',
                sortName: 'borrowId',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'userId', title: __('UserId')},
                        {field: 'phone', title: __('User')},
                        {field: 'username', title: __('Username')},
                        {field: 'fabiao_count', title: __('Fabiao_count')},
                        {field: 'fabiao_total', title: __('Fabiao_total')},
                        {field: 'manbiao_count', title: __('Manbiao_count')},
                        {field: 'manbiao_total', title: __('Manbiao_total')},
                        {field: 'cash_total', title: __('Cash_total')},
                        //{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
                        //{field: 'updateTime', title: __('UpdateTime'), formatter: Table.api.formatter.datetime},
                        //{field: 'type', title: __('Type')},
                        //{field: 'pledge', title: __('Pledge')},
                        //{field: 'isDay', title: __('IsDay')},
                        //{field: 'time', title: __('Time'), formatter: Table.api.formatter.datetime},
                        //{field: 'repayType', title: __('RepayType')},
                        //{field: 'useCards', title: __('UseCards')},
                        //{field: 'account', title: __('Account')},
                        //{field: 'raiseAccount', title: __('RaiseAccount')},
                        //{field: 'aprBase', title: __('AprBase')},
                        //{field: 'aprAdd', title: __('AprAdd')},
                        //{field: 'aprTotal', title: __('AprTotal')},
                        //{field: 'limitMoney', title: __('LimitMoney')},
                        //{field: 'validDay', title: __('ValidDay')},
                        //{field: 'interest', title: __('Interest')},
                        //{field: 'totalAccount', title: __('TotalAccount')},
                        //{field: 'repayAccount', title: __('RepayAccount')},
                        //{field: 'startTime', title: __('StartTime'), formatter: Table.api.formatter.datetime},
                        //{field: 'endTime', title: __('EndTime'), formatter: Table.api.formatter.datetime},
                        {field: 'createTime', title: __('CreateTime'), formatter: Table.api.formatter.datetime,operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD HH:mm:ss"'},
                        //{field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ],
                search: false,
                //启用普通表单搜索
                commonSearch: true,
                //可以控制是否默认显示搜索单表,false则隐藏,默认为false
                searchFormVisible: false
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});